{extend name="public/base"/}
{block name="style"}
{/block}
{block name="content"}
    <div class="data-list" data-url="{:url('purchase')}">
        <form class="layui-form inline-form">
            <div class="pull-left">
                <div class="layui-inline">
                    <select name="warehouse_id" lay-search lay-filter="data-list">
                        <option value="">仓库</option>
                        {foreach $warehouse as $w}
                        <option value="{$w.warehouse_id}">{$w.name}</option>
                        {/foreach}
                    </select>
                </div>
                <div class="layui-inline">
                    <select name="producer_id" lay-search lay-filter="data-list">
                        <option value="">供应商</option>
                        {foreach $producer as $p}
                        <option value="{$p.producer_id}">{$p.name}</option>
                        {/foreach}
                    </select>
                </div>
                <div class="layui-inline">
                    <input class="layui-input" autocomplete="off" name="purchase_sn" placeholder="采购单号">
                </div>
                <div class="layui-inline">
                    <input class="layui-input" autocomplete="off" name="producer_sn" placeholder="供应商单号">
                </div>
                <div class="layui-inline">
                    <input class="layui-input laydate-range" autocomplete="off" name="business_date" placeholder="下单时间">
                </div>
                <div class="layui-inline">
                    <input class="layui-input laydate-range" autocomplete="off" name="recv_date" placeholder="到货时间">
                </div>
                <div class="layui-inline">
                    <button class="layui-btn layui-btn-sm layui-btn-normal search"><i class="layui-icon layui-icon-search"></i></button>
                </div>
            </div>
        </form>
        <div class="layui-row form-lists-button">
            <div class="layui-inline layui-btn-group">
                <a id="batch-up" class="layui-btn layui-btn-normal layui-btn-sm"><i class="layui-icon layui-icon-vercode"></i>批量上架</a>
            </div>
        </div>
        <div class="data">
            <p><i class="fa fa-spinner fa-spin"></i>加载中...</p>
        </div>
    </div>
{/block}
{block name="script"}
<script type="text/javascript">
layui.use(['layer', 'jquery'], function()
{
    var layer = layui.layer
        , $ = layui.jquery;
    $("#batch-up").click(function()
    {
        var ids = getIds('.purchase-id');
        if(ids.length < 1)
        {
            layer.msg("请选择要上架的采购单");
            return false;
        }
        $.post("{:url('pinfo')}", {ids:ids.join(',')}).done(function(response)
        {
            var icon = 5;
            if(response.code == 1)
            {
                icon = 6;
                $(".data").closest('.data-list').getList();
            }
            layer.msg(response.msg, {icon: icon, time: 1500});
        });
    });
});
</script>
{/block}